/**
 * @param {string} num
 * @return {boolean}
 */
 var digitCount = function(num) {
  const n = num.length
  const mp = new Map()
  for(let ch of num) {
    mp.set(ch, ~~mp.get(ch) + 1)
  }
  for(let i = 0; i<n; i++) {
    if((mp.get(String(i)) || 0) !== Number(num[i])) {
      return false
    }
  }
  return true
};